//api接口统一管理
import requests from "@/api/request";

//密码登录接口
export function loginByPassword(data){
    return requests({
        url: '/loginByUserName',
        headers:{
            isToken: false
        },
        method: 'post',
        data: data,

    })
}

//注册接口
export function register(data){
    return requests({
        url: '/register',
        headers:{
            isToken: false
        },
        method: 'post',
        data: data
    })
}

//获取验证码
export function getVerificationCode(phone){
    const req = {
        phone: phone
    }
    return requests({
        url: '/getVerificationCode',
        headers:{
            isToken: false
        },
        method: 'post',
        data: req
    })
}

//手机登录接口
export function loginByPhone(data){
    return requests({
        url: '/loginByPhone',
        headers:{
            isToken: false
        },
        method: 'post',
        data: data
    })
}

//退出登录
export function logout(userId){
    const virtualAccount = {
        userId: userId
    }
    return requests({
        url: '/loginOut',
        method: 'post',
        data: virtualAccount
    })
}

//查询上一次登录时间
export function getLastLoginTime(userId){
    const reqBody = {
        userId: userId
    }
    return requests({
        url: '/getLastLoginTime',
        method: 'post',
        data: reqBody
    })
}

//查询用户信息
export function getUserInfo(userId){
    const reqBody = {
        userId: userId
    }
    return requests({
        url: '/user/getUserInfo',
        method: 'post',
        data: reqBody
    })
}

//更新用户信息
export function updateUserInfo(data){
    return requests({
        url: '/user/updateUserInfo',
        method: 'post',
        data: data
    })
}

//销户
export function cancelAccount(userId){
    const req = {
        userId: userId
    }
    return requests({
        url: '/user/cancelAccount',
        method: 'post',
        data: req
    })
}
